package org.zn.mvcbase.exception;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.http.HttpHeaders;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.ModelAndView;

/**
 * 处理不同的响应方式 执行代理
 * 
 * @ProjectName:zqdk-mvcbase
 * @Description:
 * @author: 周楠
 * @date 2017年3月6日 上午10:02:43
 */

public class ExceptionResponseHandler {

	private ExceptionResponseStateFactory factory;

	public ExceptionResponseStateFactory getFactory() {
		return factory;
	}

	public void setFactory(ExceptionResponseStateFactory factory) {
		this.factory = factory;
	}

	public ModelAndView exceptionResponse(HttpServletRequest request,
			HttpServletResponse response,
			Map<String, HttpMessageConverter<?>> converterMap, Map<String, Object> exMessage) {

		ExceptionResponseState ers = factory.getExceptionResponseState(request);
		ers.setContext(request, response, converterMap);
		ModelAndView rmv = ers.exceptionResponse(exMessage);

		return rmv;

	};

}
